package com.ajk.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajk.server.dao.HospitalLevelDictMapper;
import com.ajk.server.model.HospitalLevelDict;
import com.ajk.server.model.query.HospitalLevelDictQuery;
import com.ajk.server.service.HospitalLevelDictService;

/**
 * 医院等级  <br>
 * dict_hospital_level <br>
 * v1.0 2016-05-01
 */
 @Service
 public class HospitalLevelDictServiceImpl implements HospitalLevelDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(HospitalLevelDictServiceImpl.class);
	
	@Autowired
	private HospitalLevelDictMapper hospitalLevelDictMapper;
	
	/**
 	*根据ID删除 医院等级
 	*/
 	@Override
 	public Integer deleteHospitalLevelDictById(Integer id){
 		return hospitalLevelDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 医院等级
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertHospitalLevelDict(List<? extends HospitalLevelDict> hospitalLevelDicts){
		Integer count = hospitalLevelDictMapper.batchInsert(hospitalLevelDicts);
		return count;
 	}
 	/**
 	*新增 医院等级
 	*/
 	@Override
 	@Transactional
 	public Integer insertHospitalLevelDict(HospitalLevelDict domain){
		Integer id = hospitalLevelDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 医院等级
 	*/
 	@Override
 	@Transactional
 	public Integer updateHospitalLevelDict(HospitalLevelDict domain){
		Integer count = hospitalLevelDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 医院等级
 	*/
 	public HospitalLevelDict findHospitalLevelDictById(Integer id){
 		HospitalLevelDict result = hospitalLevelDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 医院等级
 	*/
	public List<HospitalLevelDict> findHospitalLevelDictByQuery(HospitalLevelDictQuery query){
		query.dealWith();
		List<HospitalLevelDict> result = hospitalLevelDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (HospitalLevelDict hospitalLevelDict : result) {
				hospitalLevelDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countHospitalLevelDictByQuery(HospitalLevelDictQuery query){
 		query.dealWith();
 		Integer result = hospitalLevelDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<HospitalLevelDict> findHospitalLevelDictByIds(List<Integer> ids){
 		List<HospitalLevelDict> result = hospitalLevelDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (HospitalLevelDict hospitalLevelDict : result) {
				hospitalLevelDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public HospitalLevelDict findByName(String name){
		HospitalLevelDict result = hospitalLevelDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<HospitalLevelDict> findAll(){
		List<HospitalLevelDict> result = hospitalLevelDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (HospitalLevelDict hospitalLevelDict : result) {
				hospitalLevelDict.dealWith();
			}
		}
		return result;
	}
}	